﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JobsBoardDAL;
using JobsBoardDAL.DTOs;
using JobBoardAdminPanel.ViewModels;

namespace JobBoardAdminPanel.Helpers
{
    public class ViewModelsHelper
    {
        internal static IEnumerable<IndustryViewModel> GetAllIndustries()
        {
            var industries = JobsBoardCRUD.GetIndustries();
            List<IndustryViewModel> industryVMs = new List<IndustryViewModel>();

            foreach (IndustryDTO industryDTO in industries)
            {
                industryVMs.Add(new IndustryViewModel(industryDTO));
            }

            return industryVMs;
        }

        internal static IEnumerable<OfferViewModel> GetOffersByIndustry(IndustryViewModel CurrentIndustry)
        {
            var offers = JobsBoardCRUD.GetJobOffersByIndustry(CurrentIndustry.Industry);
            List<OfferViewModel> offerVMs = new List<OfferViewModel>();

            foreach (JobOfferDTO jobOffer in offers)
            {
                offerVMs.Add(new OfferViewModel(jobOffer));
            }

            return offerVMs;
        }


        internal static IEnumerable<CompanyViewModel> GetAllCompanies()
        {
            var companies = JobsBoardCRUD.GetCompanies();
            List<CompanyViewModel> companyVMs = new List<CompanyViewModel>();

            foreach (CompanyDTO c in companies)
            {
                companyVMs.Add(new CompanyViewModel(c));
            }

            return companyVMs;
        }

        internal static IEnumerable<StatusViewModel> GetAllStatuses()
        {
            var statuses = JobsBoardCRUD.GetStatuses();
            List<StatusViewModel> statusVMs = new List<StatusViewModel>();

            foreach (StatusDTO c in statuses)
            {
                statusVMs.Add(new StatusViewModel(c));
            }

            return statusVMs;
        }

        internal static IEnumerable<CountryViewModel> GetAllCountries()
        {
            var countries = JobsBoardCRUD.GetCountries();
            List<CountryViewModel> countryVMs = new List<CountryViewModel>();

            foreach (CountryDTO c in countries)
            {
                countryVMs.Add(new CountryViewModel(c));
            }

            return countryVMs;
        }

        internal static IEnumerable<CityViewModel> GetCitiesByCountry(CountryViewModel CurrentCountry)
        {
            var cities = JobsBoardCRUD.GetCitiesByCountry(CurrentCountry.Country);
            List<CityViewModel> cityVMs = new List<CityViewModel>();

            foreach (CityDTO city in cities)
            {
                cityVMs.Add(new CityViewModel(city));
            }

            return cityVMs;
        }

        internal static IEnumerable<OfferViewModel> GetAllOffers()
        {
            var offers = JobsBoardCRUD.GetAllOffers();
            List<OfferViewModel> offerVMs = new List<OfferViewModel>();

            foreach (JobOfferDTO jobOffer in offers)
            {
                offerVMs.Add(new OfferViewModel(jobOffer));
            }

            return offerVMs;
        }

        internal static IEnumerable<CityViewModel> GetAllCities()
        {
            var cities = JobsBoardCRUD.GetCities();
            List<CityViewModel> cityVMs = new List<CityViewModel>();

            foreach (CityDTO city in cities)
            {
                cityVMs.Add(new CityViewModel(city));
            }

            return cityVMs;
        }
    }
}
